/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : structs_internal
	/// </summary>
	public class PlayerPlatformDataPOD : IPOD 
    {
        public readonly static Func<PlayerPlatformDataPOD> FACTORY = () => new PlayerPlatformDataPOD();
		public static Func<PlayerPlatformDataPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 不同SDK标识
        /// </summary>
		public string sdkName;
		/// <summary>
        /// 数据
        /// </summary>
        private Dictionary<string, string> m_attMap;
		/// <summary>
        /// 渠道号
        /// </summary>
		public string channelNo;
		
		
        public Dictionary<string, string> attMap
        {
            get
            {
                if(m_attMap == null)
                {
                    m_attMap = new();
                }
                return m_attMap;
            }
            private set => m_attMap = value;
        }
        public Dictionary<string, string> unsafe_attMap
        {
        	get => m_attMap;
        	set => m_attMap = value;
        }
		
		/*-- constructors --*/
		public PlayerPlatformDataPOD() {}
		public PlayerPlatformDataPOD(string sdkName, Dictionary<string, string> attMap, string channelNo) {
			this.sdkName = sdkName;
			this.m_attMap = attMap;
			this.channelNo = channelNo;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_string(sdkName);
            _out.Write_map_string_string(m_attMap);
            _out.Write_string(channelNo);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            sdkName = _in.Read_string();
            if(!_in.HasRemaining()) return;
            m_attMap = _in.Read_map_string_string();
            if(!_in.HasRemaining()) return;
            channelNo = _in.Read_string();
        }
		
		public PlayerPlatformDataPOD Clone() {
            PlayerPlatformDataPOD o = DynamicFactory();
            o.sdkName = sdkName;
            if (m_attMap != null) {
                o.m_attMap = new (m_attMap);
            }
            o.channelNo = channelNo;
            return o;
        }
        
        public void Clear() {
            sdkName = default;
            m_attMap = default;
            channelNo = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "PlayerPlatformDataPOD [";
			str += "sdkName=";
			str += sdkName;
			str += ", attMap=";
			str += m_attMap.ToString<string, string>();
			str += ", channelNo=";
			str += channelNo;
			str += "]";
			return str;
		}
		
	}
}